package com.supcon.exchangedata.repository.slave7;


import com.supcon.exchangedata.pojo.entity.mysql.operation.lq.LqMaintainCarBase;
import com.supcon.exchangedata.pojo.entity.mysql.operation.lq.LqMaintainCarLocus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *   路桥车辆gps信息
 * @Author: yangbin
 * @Date: 2022/04/20/9:00
 * @Description:
 */
public interface SlaveLqCarGpsInfo extends JpaRepository<LqMaintainCarLocus, Long> {

    @Transactional
    @Modifying
    @Query(nativeQuery = true,value = "SELECT * FROM lq_maintain_car_locus where id IN ( SELECT max(id) id FROM lq_maintain_car_locus where biz_time > ADDDATE(now(),interval -15 minute) and op = 'insert'  GROUP BY car_number HAVING count(*) > 1)")
    public List<LqMaintainCarLocus> findGpsCar();
}
